package com.heima.behavior.controller.v1;


import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(value = "黑马头条APP文档",tags = "黑马头条APP文档")
@RestController
@RequestMapping("/api/v1")
public class ApLikesBehaviorController {
    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;

    @Autowired
    ApReadBehaviorService apReadBehaviorService;

    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;

    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;

    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;


    @ApiOperation("保存或取消点赞行为")
    @PostMapping("/likes_behavior")
    public ResponseResult login(@RequestBody @Validated LikesBehaviorDTO dto) {
        return apLikesBehaviorService.like(dto) ;
    }

    @ApiOperation("保存阅读行为")
    @PostMapping("/read_behavior")
    public ResponseResult read(@RequestBody @Validated ReadBehaviorDTO dto) {
        return  apReadBehaviorService.readBehavior(dto);
    }

    @ApiOperation("不喜欢行为API")
    @PostMapping("/un_likes_behavior/")
    public ResponseResult collect(@RequestBody @Validated UnLikesBehaviorDTO dto) {
        return  apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @ApiOperation("收藏行为API")
    @PostMapping("/collection_behavior")
    public ResponseResult unlike(@RequestBody @Validated CollectionBehaviorDTO dto) {
        return  apCollectionBehaviorService.collectBehavior(dto);
    }

    @ApiOperation("查询文章行为相关信息")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult loadArticle(@RequestBody ArticleBehaviorDTO dto) {
        return  apArticleBehaviorService.loadArticleBehavior(dto);
    }
}
